package net.lzzy.practices.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "options")
@Getter
@Setter
public class Option  extends BaseEntity{
    private String content;
    private String label;
    private boolean answer;
    @ManyToOne
    private Question question;

    @ManyToMany(mappedBy = "options")
    private List<Result> results=new ArrayList<>();

    @JsonIgnore
    public List<Result> getResults() {
        return results;
    }

    public Option(){};
    @JsonBackReference
    public Question getQuestion() {
        return question;
    }
}
